//
//  ReSetPasswordThreeViewController.m
//  SIPphone
//
//  Created by wrt on 15-2-5.
//  Copyright (c) 2015年 wrtsoft. All rights reserved.
//

#import "ReSetPasswordThreeViewController.h"
#import "SVProgressHUD.h"
#import "TPKeyboardAvoidingScrollView.h"

@interface ReSetPasswordThreeViewController ()

@end

@implementation ReSetPasswordThreeViewController


- (id)initWithUserName:(NSString *)userName
{
    self = [super init];
    if (self)
    {
        self.username = [[NSString alloc] init];
        self.username = userName;
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.errorLabel.text = @"";
    [[NetPostClass shareNetPostClass] setDelegate:self];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //判断版本号 然后选择相应的ui界面
    float systemVersion = iOSValue;
    if (systemVersion >= 7.0)
    {
        self.edgesForExtendedLayout=UIRectEdgeNone;
    }
    [self.scrollView contentSizeToFit];
    self.title = NSLocalizedString(@"password Reset", @"密码重置 Password Reset");
}

- (IBAction)finishButtonPressed:(id)sender
{
    if (self.passwordTextField.text.length > 0 && self.reNewPasswordTextField.text.length > 0 && self.checkCodeTextField.text.length > 0)
    {
        if ([self.passwordTextField.text isEqualToString:self.reNewPasswordTextField.text])
        {
            [[NetPostClass shareNetPostClass] postReSetPasswordWithUserName:self.username andPassWord:self.passwordTextField.text andVerification:self.checkCodeTextField.text];
        }
        else
        {
            self.errorLabel.text = NSLocalizedString(@"the two passwords do not match", @"两次密码不一致 The two passwords do not match");
        }
    }
    else
    {
        self.errorLabel.text = NSLocalizedString(@"please fill out the complete contents", @"请将内容填写完整 Please fill out the complete contents");
    }
}

#pragma NetPostDelegateMethod
/**
 *  post数据成功回调
 *
 *  @param comeBackDic 返回来的字典数据
 *  @param tagNumber   post的tag标识
 */
- (void)postSuccessfulWithString:(NSDictionary *)comeBackDic withTag:(int)tagNumber
{
    [SVProgressHUD showSuccessWithStatus:NSLocalizedString(@"successfully modified", @"修改成功 Successfully modified")];
    self.errorLabel.text = @"";
    
    [self dismissModalViewControllerAnimated:YES];
}
/**
 *  post失败返回数据
 *
 *  @param faileString 失败的原因
 *  @param tagNumber   post的tag标识
 */
- (void)postFailedWithString:(NSString *)faileString withTag:(int)tagNumber
{
    //post失败返回的失败原因
    self.errorLabel.text = NSLocalizedString(@"重新修改密码失败，请检查验证码是否正确以及网络是否正常", @"重新修改密码失败，请检查验证码是否正确以及网络是否正常 Again failed to change the password, check the code is correct and that the network is normal");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
